package com.hsy.crm.web.service.asyn;

import org.springframework.stereotype.Service;

@Service
public class AsynStoreInServcie{/*

    @Autowired
    AsynStoreOutServcie asynStoreOutServcie;

    @Autowired
    StoreProductDetailMapper storeProductDetailMapper;

    *//**
     * 只要是销售退货 --  都是重复入库
     *
     * 重复入库分两种情况：知道明细  不知道明细
     * @param message
     * @param storeProductDetail
     *//*
    public void init(Message message, StoreProductDetail storeProductDetail){

        StoreProductDetail repeatStoreProductDetail = storeProductDetailMapper.selectRepeatSortDetail(storeProductDetail);

        if( repeatStoreProductDetail == null ){
            this.unCalc(message,storeProductDetail.getStoreProductId(),storeProductDetail.getNumber());
        }else{
            System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxx");
        }

    }

    public void unCalc(Message message, Long storeProductId,long number){
        StoreProductDetail unStoreProductDetail = this.selectUnStoreProductDetail(message,storeProductId);
        if( unStoreProductDetail != null ){
            unStoreProductDetail.setCustomerId(message.getCustomerId());
            //asynStoreOutServcie.calcStoreProductDetailDone(message,unStoreProductDetail);
            long currUnNumber = unStoreProductDetail.getNumber() - unStoreProductDetail.getOutNumber();
            if( number > currUnNumber ){
                number -= currUnNumber;
                this.unCalc(message,storeProductId,number);
            }
        }
    }

    private StoreProductDetail selectUnStoreProductDetail(Message message, Long storeProductId){
        StoreProductDetail select = new StoreProductDetail();
        select.setCustomerId(message.getCustomerId());
        select.setStoreProductId(storeProductId);
        return storeProductDetailMapper.getUnCalcStoreProductDetail(select);


    }*/

}